home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / libwww2 / HTAnchor.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  8.9 KB  |  298 lines

  1. /*      Hypertext "Anchor" Object                                    HTAnchor.h
  2. **      ==========================
  3. **
  4. **      An anchor represents a region of a hypertext document which is linked
  5. **      to another anchor in the same or a different document.
  6. */
  7.  
  8. #ifndef HTANCHOR_H
  9. #define HTANCHOR_H
  10.  
  11. /* Version 0 (TBL) written in Objective-C for the NeXT browser */
  12. /* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independant */
  13.  
  14. #include "HTList.h"
  15. #include "HTAtom.h"
  16.  
  17. #ifdef SHORT_NAMES
  18. #define HTAnchor_findChild                      HTAnFiCh
  19. #define HTAnchor_findChildAndLink               HTAnFiLi
  20. #define HTAnchor_findAddress                    HTAnFiAd
  21. #define HTAnchor_delete                         HTAnDele
  22. #define HTAnchor_makeLastChild                  HTAnMaLa
  23. #define HTAnchor_parent                         HTAnPare
  24. #define HTAnchor_setDocument                    HTAnSeDo
  25. #define HTAnchor_document                       HTAnDocu
  26. #define HTAnchor_setFormat                      HTAnSeFo
  27. #define HTAnchor_format                         HTAnForm
  28. #define HTAnchor_setIndex                       HTAnSeIn
  29. #define HTAnchor_isIndex                        HTAnIsIn
  30. #define HTAnchor_address                        HTAnAddr
  31. #define HTAnchor_hasChildren                    HTAnHaCh
  32. #define HTAnchor_title                          HTAnTitl
  33. #define HTAnchor_setTitle                       HTAnSeTi
  34. #define HTAnchor_appendTitle                    HTAnApTi
  35. #define HTAnchor_link                           HTAnLink
  36. #define HTAnchor_followMainLink                 HTAnFoMa
  37. #define HTAnchor_followTypedLink                HTAnFoTy
  38. #define HTAnchor_makeMainLink                   HTAnMaMa
  39. #define HTAnchor_setProtocol                    HTAnSePr
  40. #define HTAnchor_protocol                       HTAnProt
  41. #define HTAnchor_physical                       HTAnPhys
  42. #define HTAnchor_setPhysical                    HTAnSePh
  43. #define HTAnchor_methods                        HtAnMeth
  44. #endif
  45.  
  46. /*                      Main definition of anchor
  47. **                      =========================
  48. */
  49.  
  50. typedef struct _HyperDoc HyperDoc;  /* Ready for forward references */
  51. typedef struct _HTAnchor HTAnchor;
  52. typedef struct _HTParentAnchor HTParentAnchor;
  53.  
  54. /*      After definition of HTFormat: */
  55. #include "HTFormat.h"
  56.  
  57. typedef HTAtom HTLinkType;
  58.  
  59. typedef struct {
  60.   HTAnchor *    dest;           /* The anchor to which this leads */
  61.   HTLinkType *  type;           /* Semantics of this link */
  62. } HTLink;
  63.  
  64. struct _HTAnchor {              /* Generic anchor : just links */
  65.   HTLink        mainLink;       /* Main (or default) destination of this */
  66.   HTList *      links;          /* List of extra links from this, if any */
  67.   /* We separate the first link from the others to avoid too many small mallocs
  68.      involved by a list creation. Most anchors only point to one place. */
  69.   HTParentAnchor * parent;      /* Parent of this anchor (self for adults) */
  70. };
  71.  
  72. struct _HTParentAnchor {
  73.   /* Common part from the generic anchor structure */
  74.   HTLink        mainLink;       /* Main (or default) destination of this */
  75.   HTList *      links;          /* List of extra links from this, if any */
  76.   HTParentAnchor * parent;      /* Parent of this anchor (self) */
  77.  
  78.   /* ParentAnchor-specific information */
  79.   HTList *      children;       /* Subanchors of this, if any */
  80.   HTList *      sources;        /* List of anchors pointing to this, if any */
  81.   HyperDoc *    document;       /* The document within which this is an anchor */
  82.   char *        address;        /* Absolute address of this node */
  83.   HTFormat      format;         /* Pointer to node format descriptor */
  84.   BOOL          isIndex;        /* Acceptance of a keyword search */
  85.   char *        title;          /* Title of document */
  86.  
  87.   HTList*       methods;        /* Methods available as HTAtoms */
  88.   void *        protocol;       /* Protocol object */
  89.   char *        physical;       /* Physical address */
  90. };
  91.  
  92. typedef struct {
  93.   /* Common part from the generic anchor structure */
  94.   HTLink        mainLink;       /* Main (or default) destination of this */
  95.   HTList *      links;          /* List of extra links from this, if any */
  96.   HTParentAnchor * parent;      /* Parent of this anchor */
  97.  
  98.   /* ChildAnchor-specific information */
  99.   char *        tag;            /* Address of this anchor relative to parent */
  100. } HTChildAnchor;
  101.  
  102.  
  103. /*      Create new or find old sub-anchor
  104. **      ---------------------------------
  105. **
  106. **      This one is for a new anchor being edited into an existing
  107. **      document. The parent anchor must already exist.
  108. */
  109.  
  110. extern HTChildAnchor * HTAnchor_findChild
  111.   PARAMS(
  112.      (HTParentAnchor *parent,
  113.       CONST char *tag)
  114.   );
  115.  
  116. /*      Create or find a child anchor with a possible link
  117. **      --------------------------------------------------
  118. **
  119. **      Create new anchor with a given parent and possibly
  120. **      a name, and possibly a link to a _relatively_ named anchor.
  121. **      (Code originally in ParseHTML.h)
  122. */
  123. extern HTChildAnchor * HTAnchor_findChildAndLink
  124.   PARAMS((
  125.       HTParentAnchor * parent,  /* May not be 0 */
  126.       CONST char * tag,         /* May be "" or 0 */
  127.       CONST char * href,        /* May be "" or 0 */
  128.       HTLinkType * ltype        /* May be 0 */
  129.   ));
  130.  
  131.  
  132. /*      Create new or find old named anchor
  133. **      -----------------------------------
  134. **
  135. **      This one is for a reference which is found in a document, and might
  136. **      not be already loaded.
  137. **      Note: You are not guaranteed a new anchor -- you might get an old one,
  138. **      like with fonts.
  139. */
  140.  
  141. extern HTAnchor * HTAnchor_findAddress
  142.   PARAMS(
  143.      (CONST char * address)
  144.      );
  145.  
  146.  
  147. /*      Delete an anchor and possibly related things (auto garbage collection)
  148. **      --------------------------------------------
  149. **
  150. **      The anchor is only deleted if the corresponding document is not loaded.
  151. **      All outgoing links from parent and children are deleted, and this anchor
  152. **      is removed from the sources list of all its targets.
  153. **      We also try to delete the targets whose documents are not loaded.
  154. **      If this anchor's source list is empty, we delete it and its children.
  155. */
  156.  
  157. extern BOOL HTAnchor_delete
  158.   PARAMS(
  159.      (HTParentAnchor *me)
  160.      );
  161.  
  162.  
  163. /*              Move an anchor to the head of the list of its siblings
  164. **              ------------------------------------------------------
  165. **
  166. **      This is to ensure that an anchor which might have already existed
  167. **      is put in the correct order as we load the document.
  168. */
  169.  
  170. extern void HTAnchor_makeLastChild
  171.   PARAMS(
  172.      (HTChildAnchor *me)
  173.      );
  174.  
  175. /*      Data access functions
  176. **      ---------------------
  177. */
  178.  
  179. extern HTParentAnchor * HTAnchor_parent
  180.   PARAMS(
  181.      (HTAnchor *me)
  182.      );
  183.  
  184. extern void HTAnchor_setDocument
  185.   PARAMS(
  186.      (HTParentAnchor *me, HyperDoc *doc)
  187.      );
  188.  
  189. extern HyperDoc * HTAnchor_document
  190.   PARAMS(
  191.      (HTParentAnchor *me)
  192.      );
  193. /* We don't want code to change an address after anchor creation... yet ?
  194. extern void HTAnchor_setAddress
  195.   PARAMS(
  196.      (HTAnchor *me, char *addr)
  197.      );
  198. */
  199.  
  200. /*      Returns the full URI of the anchor, child or parent
  201. **      as a malloc'd string to be freed by the caller.
  202. */
  203. extern char * HTAnchor_address
  204.   PARAMS(
  205.      (HTAnchor *me)
  206.      );
  207.  
  208. extern void HTAnchor_setFormat
  209.   PARAMS(
  210.      (HTParentAnchor *me, HTFormat form)
  211.      );
  212.  
  213. extern HTFormat HTAnchor_format
  214.   PARAMS(
  215.      (HTParentAnchor *me)
  216.      );
  217.  
  218. extern void HTAnchor_setIndex
  219.   PARAMS(
  220.      (HTParentAnchor *me)
  221.      );
  222.  
  223. extern BOOL HTAnchor_isIndex
  224.   PARAMS(
  225.      (HTParentAnchor *me)
  226.      );
  227.  
  228. extern BOOL HTAnchor_hasChildren
  229.   PARAMS(
  230.      (HTParentAnchor *me)
  231.      );
  232.  
  233. /*      Title handling
  234. */
  235. extern CONST char * HTAnchor_title
  236.   PARAMS(
  237.      (HTParentAnchor *me)
  238.      );
  239.  
  240. extern void HTAnchor_setTitle
  241.   PARAMS(
  242.      (HTParentAnchor *me, CONST char * title)
  243.      );
  244.  
  245. extern void HTAnchor_appendTitle
  246.   PARAMS(
  247.      (HTParentAnchor *me, CONST char * title)
  248.      );
  249.  
  250. /*      Link this Anchor to another given one
  251. **      -------------------------------------
  252. */
  253.  
  254. extern BOOL HTAnchor_link
  255.   PARAMS(
  256.      (HTAnchor *source, HTAnchor *destination, HTLinkType *type)
  257.      );
  258.  
  259. /*      Manipulation of links
  260. **      ---------------------
  261. */
  262.  
  263. extern HTAnchor * HTAnchor_followMainLink
  264.   PARAMS(
  265.      (HTAnchor *me)
  266.      );
  267.  
  268. extern HTAnchor * HTAnchor_followTypedLink
  269.   PARAMS(
  270.      (HTAnchor *me, HTLinkType *type)
  271.      );
  272.  
  273. extern BOOL HTAnchor_makeMainLink
  274.   PARAMS(
  275.      (HTAnchor *me, HTLink *movingLink)
  276.      );
  277.  
  278. /*      Read and write methods
  279. **      ----------------------
  280. */
  281. extern HTList * HTAnchor_methods PARAMS((HTParentAnchor *me));
  282.  
  283. /*      Protocol
  284. **      --------
  285. */
  286. extern void * HTAnchor_protocol PARAMS((HTParentAnchor * me));
  287. extern void HTAnchor_setProtocol PARAMS((HTParentAnchor * me,
  288.                                         void* protocol));
  289.  
  290. /*      Physical address
  291. **      ----------------
  292. */
  293. extern char * HTAnchor_physical PARAMS((HTParentAnchor * me));
  294. extern void HTAnchor_setPhysical PARAMS((HTParentAnchor * me,
  295.                                         char * protocol));
  296.  
  297. #endif /* HTANCHOR_H */
  298.